package ace.cmp.spring.data.jdbc.test.dao.repository;

import ace.cmp.spring.data.jdbc.test.dao.entity.CasUser;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @author caspar
 * @date 2023/2/10 17:28 spring data 常用接口
 */
@Slf4j
@AllArgsConstructor
public class CASUserRepositoryExImpl implements CASUserRepositoryEx {
  private final JdbcTemplate jdbcTemplate;

  @Override
  public List<CasUser> findCustomAll(String name) {
    log.info("{}", jdbcTemplate);

    return jdbcTemplate.query(
        "SELECT * FROM cas_user WHERE name='" + name + "'",
        new BeanPropertyRowMapper<>(CasUser.class));
  }
}
